<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>店铺首页</title>

<link href="<?php echo $this->_webroot('/style/jq-ui/jquery-ui-1.8.18.custom.css'); ?>" rel="stylesheet" type="text/css">
<link href="<?php echo $this->_webroot('/style/css.css'); ?>" rel="stylesheet" type="text/css">
<link href="<?php echo $this->_webroot('/style/content.css'); ?>" rel="stylesheet" type="text/css">
<script type="text/javascript" src="<?php echo $this->_webroot('script/jquery-1.7.1.min.js'); ?>"></script>
<script type="text/javascript" src="<?php echo $this->_webroot('script/jquery-ui-1.8.18.custom.min.js'); ?>"></script>
<script type="text/javascript" src="<?php echo $this->_webroot('script/jquery.carouFredSel-5.5.0-packed.js'); ?>"></script>
<script type="text/javascript" src="<?php echo $this->_webroot('script/js.js'); ?>"></script>
<script type="text/javascript" src="<?php echo $this->_webroot('script/content.js'); ?>"></script>
</head>

<body>

<psp:tags     htmlname='shop_topnav'  iconname='shoptopnav' />

<div class="head headpadding">
    <psp:tags     htmlname='shopsearch_default'  iconname='shopsearch_default' />
    <div class="clear"></div>
</div>
<!-- nav_wrap -->
<div class="nav_wrap">
	<div class="nav_logo"><img src="<?php if(!empty($SHOP['shop_template_img'])) {echo $SHOP['shop_template_img'];}else{echo $this->_webroot('photo/company_logo.jpg');}?>"  onerror="this.src='<?php echo $this->_webroot('photo/company_logo.jpg'); ?>'" width="998" height="154" /></div>
    <div class="nav_content_wrap">
    	<img src="<?php echo $this->_webroot('images/nav_bg_left.gif'); ?>" width="5" height="38" class="nav_content_left" />
        <div class="nav_content">
        	<ul class="nav_list">
                <psp:tags     htmlname='shopnav_vip'  iconname='shopnav' />  
            </ul>
        </div>
        <img src="<?php echo $this->_webroot('images/nav_bg_right.gif'); ?>" width="5" height="38"  class="nav_content_left" />
        <div class="clear"></div>
    </div>
</div>
<!-- nav_wrap end -->

<div class="container">
	<div class="mod1">
		<psp:tags     htmlname='shopleftmenu_vip'  iconname='shopleftmenu_vip' />	
        
        <div class="scroll-boxs width2">
        	<div class="slideShow1">
            	<ul class="mainSlideShow1">
            <?php  $i=0 ; if($promote_goods) {
                foreach($promote_goods as $value){  $i++; if($i>4)break;  ?>				
                	<li><a href="<?php echo $this->_url('shop/productshow/'.$value['goods']['id']);?>"><img src="<?php echo  $value['goods']['is_set_image'] ? $value['goods']['goods_thumb'] : 'skin/default/images/nopic.gif';?>" alt="" width="579" height="251" /></a></li>
            <?php } }?>					
                </ul>
                <div class="slideShowTab">
                	<ul id="slideShowTab">
          <?php $i=0 ; if($promote_goods) {
          foreach($promote_goods as $value){ $i++; if($i>4)break; ?>					
                    	<li <?php if($i==1) { ?>class="selected"<?php } ?>><?php echo $i;?></li>
          <?php } }?>
                    </ul>
                </div>
            </div>
            
            <div class="slideScroll1">
            	<a href="#" class="slideScrollLeftBtn1"></a>
                <div class="slideScrollBox1">
        <?php
		$query = array(
            'conditions' => array('goods.shop_id'=>$SHOP['id'],'goods.is_hot'=>1,'goods.is_on_sale'=>1,'goods.lock_flg'=>0),
            'order'=>'sort_order asc,id desc',
            'limit'=>8,
			'fields' => array('goods.*'), 
		);
        $hot_goods = POP::exe('[@@:UM goods][@@:QU find:all]',$query);
		
        ?>					
                    <ul class="mainSlideScroll1">
            <?php if($hot_goods) {
            foreach($hot_goods as $value){?>					
                        <li><a href="<?php echo $this->_url('shop/productshow/'.$value['goods']['id']);?>"><img src="<?php echo  $value['goods']['is_set_image'] ? $value['goods']['goods_thumb'] : $this->_webroot('photo/sale_prot_img1.gif');?>"  onerror="this.src='<?php echo $this->_webroot('photo/sale_prot_img1.gif'); ?>'"  width="115" height="79" /></a></li>
          <?php } }?>                       
                    </ul>
                </div>
                <a href="#" class="slideScrollRightBtn1"></a>
            </div>
        </div>
        
        <div class="sidebar1">
        	<div class="gonggao1">
            	<div class="gonggao_hd">
                	<div class="left">最新公告</div>
                </div>
                <p class="gonggao_content"><?php echo $SHOP['shop_notice'];?></p>
            </div>
            
            <div class="trends">
            	<div class="hd">
                	<div class="left">最新动态</div><div class="right"><a href="<?php echo $this->_url('shop/news/'.$SHOP['id']);?>">+更多</a></div>
                </div>
				<?php
		$query = array(
            'conditions' => array('shoparticle.shop_id' => $SHOP['id'],'shoparticle.is_show' => 1),
            'order'=>'id desc',
            'limit'=>5,
			'fields' => array('shoparticle.*'), 
		);
		$shoparticlelist = POP::exe('[@@:UM shoparticle][@@:QU find:all]',$query);
		$query = array(
			'fields' => array('shoparticlecat.*'), 
		);
		$catlist = POP::exe('[@@:UM shoparticlecat][@@:QU find:all]',$query);

		$catinfo = array();
        foreach($catlist as $key => $value) {
            $catinfo[$value['shoparticlecat']['id']] = $value['shoparticlecat'];
        }  			
				?>
                <ul class="dongtai_content">
            <?php if($shoparticlelist) {
            foreach($shoparticlelist as $value){?>				
                	<li><span class="dongtai_cat">&lt;&lt;&nbsp;[<a href="<?php echo $this->_url('shop/news/'.$SHOP['id'].'?id='.$value['shoparticle']['cat_id']);?>"><?php echo $catinfo[$value['shoparticle']['cat_id']]['cat_name'];?></a>]</span>
					<a class="dongtai_title" href="<?php echo $this->_url('shop/newshow/'.$SHOP['id'].'/'.$value['shoparticle']['id']);?>"><?php echo $value['shoparticle']['title'];?></a></li>
           <?php } }?>                    

                </ul>
            </div>
        </div>
    </div>
</div>
<div class="main_content2">
	<div class="main_content2_left">
        <!--  客服中心 -->
		<psp:tags     htmlname='shopservice_vip'  iconname='shopservice_vip' />
        <!--  客服中心 end -->
        
        <!-- 销量排行 -->
        <div class="ranked_sales_wrap">
        	<div class="ranked_sales_hd">
               <div class="left1">推荐商家</div><div class="right1"><!--<a href="#">+更多</a>--></div>           
            </div>
            <ul class="rank_list_content display1">
			    <?php foreach($shoplinks as $value) { $value=$value['shoplinks']; ?>
            	<li>
                	<a href="" class="prot_img_a"><img src="<?php echo $value['pic'];?>"  onerror="this.src='<?php echo $this->_webroot('photo/sale_prot_img1.gif'); ?>'" width="41" height="37" /></a>
                    <div class="rank_prot_content">
                    	<a href="<?php echo $value['url'];?>" target="<?php echo $value['target'];?>" class="rank_prot_title"><?php echo $value['name'];?></a>
                        <p class="rank_prot_p"><?php echo $value['content'];?></p>
                    </div>
                </li>
				<?php } ?>

                <div class="clear"></div>
            </ul> 
            <div class="clear"></div>          
          
        </div>
        <!-- 销量排行 -->
        <div class="clear"></div>
    </div>
    
    <!-- 店铺推荐 -->
	<div class="shop_recommend_wrap">
    	<div class="shop_recommend_hd">
        	<span class="recommend_label">店铺推荐</span>
            <a href="<?php echo $this->_url('shop/products/'.$SHOP['id']);?>" class="more1">+更多</a>
        </div>
        <div class="shoprecommend_wrap">
        	<ul class="pro_list_padding">
            <?php if($best_goods) {
            foreach($best_goods as $value){?>			
            	<li>
                	<div class="prot_img">
                      	<span class="newprot">新品上市</span>
                       	<a href="<?php echo $this->_url('shop/productshow/'.$value['goods']['id']);?>"><img src="<?php echo  $value['goods']['is_set_image'] ? str_replace('thumb_','',$value['goods']['goods_thumb']) : 'skin/default/images/nopic.gif';?>" alt="" width="160px" height="120px" /></a>
                    </div>
                    <div class="title"><a href="<?php echo $this->_url('shop/productshow/'.$value['goods']['id']);?>"><?php echo  $value['goods']['goods_name'];?></a></div>
                    <div class="attribute"><span>零售价：</span><span>￥<?php echo  $value['goods']['goods_refer_price'];?></span></div>
					<?php if (empty($shop_customer)) { ?>
                    <div class="attribute"><span>爱搜价：</span><span><?php if (isset($this->controller->my->id)) { ?>￥<?php echo  $value['goods']['goods_price'];?><?php }else{ ?>会员可见<?php } ?></span></div>
					<?php } else { ?>
                    <div class="attribute vip"><span><img src="<?php echo $this->_webroot('images/vip1.jpg'); ?>" />：</span><span class="vipPrice1">￥<?php echo  (($value['goods']['goods_price'] * $shop_customer['rebate'])/10) ;?></span></div>
					<?php } ?>
                    <div class="attribute"><span>库存：</span><span><?php echo  $value['goods']['goods_number'];?>件</span></div>
                    <div class="attribute attribute1">
                    	<span>数量：</span><a class="cutOrder" href="#"><img src="<?php echo $this->_webroot('images/cutNum.jpg'); ?>" /></a><input type="text" class="orderNum"  id="num<?php echo $v['id'] ;?>" name="num<?php echo $v['id'] ;?>"  value="1" /><a class="addOrder" href="#"><img src="<?php echo $this->_webroot('images/addNum.jpg'); ?>" /></a>
                    </div>
                    <input type="submit" class="orderBtn" value=""  onclick="javascript:addCart(<?php echo $v['id'] ;?>);" />
                </li>
            <?php }?>
            <?php }?>
                <div class="clear"></div> 
            <input type="hidden" value="<?php echo  $this->controller->my->id;?>" id="shop_user" />
			<input type="hidden" value="<?php echo  $SHOP['id'];?>" id="shop_id" />				
<script language="JavaScript" src="<?php echo $this->_webroot('servtools/ajax_client/ajax.js');?>"></script>
<script language="JavaScript">
	<!--
		function addCart(id) {
			var num = document.getElementById('num'+id);
			var shop_id = document.getElementById('shop_id').value;
			var user_id = document.getElementById('shop_user').value;
			
			var num_reg = /^(\d+)$/;
			if(!num_reg.test(num.value)){
				alert('购买数量格式不正确!');
				return;
			}
			if(num.value=='0'){
				alert('购买数量不能为0！');
				return;
			}

			if (shop_id == user_id){
				alert('自己的商品不能放入购物车');
			}else{
				ajax("<?php echo $this->_url('shop/goodsaddcart');?>","POST","id="+id+"&num="+num.value,function(data){
					if(data == 1) {
						alert("已成功添加到您的购物车！");
					} else if(data == -1) {
						alert("此商品已在您的购物车里！");
					} else if(data == -2) {
						alert("库存里没有这么多商品！");
					} else {
						alert("添加失败，请确认您是否已登陆！");
					}
				});
			}
		}
	-->	
</script>					
             </ul>
             <div class="clear"></div>           
        </div>
    </div>
	<!-- 店铺推荐 end -->
	<div class="clear"></div>
</div>

<!-- 友情链接 -->
<psp:tags     htmlname='links'  iconname='links' />
<!-- 友情链接 end -->

<div class="clear"></div>

<psp:tags     htmlname='default_footer'  iconname='defaultfooter' />
</body>
</html>